package ain.standard;

import util.Vector;
import environment.Pitch;
import environment.Team;
import environment.player.Player;

public class StandardShootAntibody extends StandardAbstractAntibody
{
	private static int ID = 0;
	
	public StandardShootAntibody(Player player, Pitch pitch)
	{
		super(player, pitch);
	}
	
	public void execute()
	{
		// shoots ball towards opponent goal
		
		// direction is the vector pointing from ball to target; kick is executed with max force
		Vector impulseDirection = Vector.substract(player.getOpponentGoal(), pitch.getBall().getPosition());
		impulseDirection.normalize();
		impulseDirection.multiply(player.getMaxKickImpulse());
		
		player.kick(impulseDirection);
	}
	
	protected double distBallRatioValue(double ratio)
	{
		return (ratio <= 2) ? 1 - (ratio / 2) : 0;
	}
	
	protected double distBallGoalValue(double zoneNumber)
	{		
		if (zoneNumber >= ((2.0/3) * 5))
		{
			return (zoneNumber - (2.0/3) * 5) / ((1.0/3) * 5);
		}
		
		return 0;
	}
	
	protected double imprDistBallGoalValue(double zoneNumber)
	{
		if (zoneNumber >= (1 + (8.0/3.0)))
		{
			return (zoneNumber - (1 + (8.0/3.0))) / (4.0/3.0);
		}
		
		return 0;
	}
	
	protected double distBallPlayerValue(double distance)
	{
		if (distance <= FAR_RADIUS)
		{
			return 1 - (distance / FAR_RADIUS);
		}
		else return 0;
	}
	
	public int getID()
	{
		return ID;
	}
	
	public String toString()
	{
		return "Shoot";
	}
}
